# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Grigory Kirillov <txgk@bk.ru>
pkgname=litehtml
pkgver=0.6
pkgrel=0
pkgdesc="Fast and lightweight HTML/CSS rendering engine"
url="http://www.litehtml.com"
arch="all"
license="BSD-3-Clause"
makedepends="cmake samurai gumbo-parser-dev"
checkdepends="gtest-dev gmock"
subpackages="$pkgname-static $pkgname-dev"
source="https://github.com/litehtml/litehtml/archive/v$pkgver/litehtml-$pkgver.tar.gz
	local-test.patch"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DLITEHTML_UTF8=ON \
		-DEXTERNAL_GUMBO=ON \
		-DBUILD_TESTING=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)"
	cmake -B build-static -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DLITEHTML_UTF8=ON \
		-DEXTERNAL_GUMBO=ON \
		-DBUILD_TESTING=OFF
	cmake --build build
	cmake --build build-static
}

check() {
	ctest --output-on-failure --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	DESTDIR="$pkgdir" cmake --install build-static
}

sha512sums="
b774ed96e53780865e789875f571f96ebce1cd2ff0c05a06ae68a67aec44375cc282c07f77fc87131d422aceddba32bbf3e8e498c870883d8e042adb30834c39  litehtml-0.6.tar.gz
8327b4683b18d82bc930a53c95179c8daec4b7eed7f1486dd4bd6fc8a2fde95ff42ee36c1854813bf82b729d898310e7e2df78535b56ef924df12010e9a615ca  local-test.patch
"
